/*
* Copyright (c) 2008, Vladimir Gumenuk
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*     * Redistributions of source code must retain the above copyright
*       notice, this list of conditions and the following disclaimer.
*     * Redistributions in binary form must reproduce the above copyright
*       notice, this list of conditions and the following disclaimer in the
*       documentation and/or other materials provided with the distribution.
*     * Neither the name of the copyright holder nor the
*       names of its contributors may be used to endorse or promote products
*       derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#pragma once

class CGNXEdit;

// CGNXSpin
class CGNXSpin : public CSpinButtonCtrl
{
    DECLARE_DYNAMIC(CGNXSpin)
public:
    CGNXSpin();
    virtual ~CGNXSpin();

    void Initialize( int iMin, int iMax, CGNXEdit *pEdit );
    void SetValue( int i );
    int  GetValue();

protected:
    BOOL OnDeltapos( NMHDR* pNMHDR, LRESULT* pResult );
    DECLARE_MESSAGE_MAP()

private:
    int             m_iMin;
    int             m_iMax;
    CGNXEdit       *m_pEdit;
};

// CGNXEdit
class CGNXEdit : public CEdit
{
    DECLARE_DYNAMIC(CGNXEdit)

public:
	CGNXEdit();
	virtual ~CGNXEdit();

    __declspec(property(get=GetValue, put=SetValue)) int Value;
    __declspec(property(get=GetFltValue, put=SetFltValue)) float fValue;
    __declspec(property(get=GetVisible, put=SetVisible)) BOOL Visible;

    void DataExchange( CDataExchange *pDX, int iIDEdit, int iIDSpin );

    void Initialize( int iMin, int iMax );
    void Initialize( float fMin, float fMax, int iSpinMin, int iSpinMax );
    void SetValue( int i );
    int  GetValue();

    void  SetFltValue( float f );
    float GetFltValue();

    VARTYPE GetParamType() { return m_vt; }

    BOOL GetVisible();
    void SetVisible( BOOL bVis );

protected:
    afx_msg void OnEditCtrlChanged();
	DECLARE_MESSAGE_MAP()

private:
    VARTYPE     m_vt;
    float       m_fMin;
    float       m_fMax;
    int         m_iMin;
    int         m_iMax;
    int         m_iSpinMin;
    int         m_iSpinMax;
    CGNXSpin    m_Spin;
};

//////////////////////////////////////////////////////////////////////////
// CGNXCheckBox
class CGNXCheck : public CButton
{
    DECLARE_DYNAMIC(CGNXCheck)

public:
    CGNXCheck()
    {
        m_pData = NULL;
    }

    void Initialize( LPWORD pDataContainer )
    {
        ASSERT( pDataContainer );
        m_pData = pDataContainer;

        WORD wValue = *m_pData;
        SetCheck( wValue );
    }

protected:
    afx_msg void OnBtnClicked();
    DECLARE_MESSAGE_MAP()

private:
    LPWORD    m_pData;
};